package durose.system.springUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import durose.system.pojo.Empl;


import durose.system.service.BossService;
import durose.system.service.DeptService;


/**
 * 获取分页对象，重新封装
 * @author Administrator
 *
 */
@Component
public class SpringEmplFactory {

	@Autowired 
BossService bossService; 
@Autowired 
DeptService deptService; 

	
	
	public static SpringEmplFactory me(){
		 return SpringContextHolder.getBean("springEmplFactory");
	}
	
	//将List<Boss>格式的数据 改造成List<Map<String,Object>>类型，并在此处初始化一对多
	public List<Map<String,Object>> initData(List<Empl> emples){
		List<Map<String,Object>> mapList = new ArrayList<>();
		for(Empl empl:emples){
			Map<String,Object> map  = new HashMap<String, Object>();
			map.put("empl_id",empl.getEmpl_id());
map.put("empl_picture",empl.getEmpl_picture());
map.put("empl_name",empl.getEmpl_name());
map.put("empl_number",empl.getEmpl_number());
map.put("empl_sex",empl.getEmpl_sex());
map.put("empl_age",empl.getEmpl_age());
map.put("empl_birthday",empl.getEmpl_birthday());
map.put("empl_hobby",empl.getEmpl_hobby());
map.put("empl_self",empl.getEmpl_self());
map.put("empl_banknumber",empl.getEmpl_banknumber());
map.put("empl_boss",bossService.bossGet(empl.getEmpl_boss()).getBoss_name());
map.put("empl_dept",deptService.deptGet(empl.getEmpl_dept()).getDept_name());
map.put("empl_birthplace",empl.getEmpl_birthplace());
map.put("empl_money",empl.getEmpl_money());

			mapList.add(map);
		}
		return mapList;
	}
	
	
}
